<?php

class Application_Form_Analise extends Zend_Form
{

 public function __construct($colunas, $dados=null, $marcadorAntigo ="", $option=null)

   {
   		parent::__construct($option);
   			       
       $this->setMethod('post');
       
       //          $this->addElement($marcador);
       
       foreach ($colunas as $key =>  $coluna){
       
       	if($key > 0){
       		//echo $coluna;	
       	//Campo SSR
       $campo=$this->CreateElement('text',$coluna)
                   // ->setLabel('SSR:')
                    ->setValue($dados[$coluna])
                    ->addValidator('alnum')
                    ->setAttrib('size', 1)
                    ->setAttrib('maxLength', 1)
               		//->addValidator('regex', false, array('/^[a-z]+/'))
                    //->addValidator('stringLength', true, array(1, 1))
                    ->setRequired(true)
                    ->addFilter('StringToLower');

       $campo->setDecorators(array(
                   'ViewHelper',
                   'Description',
                   'Errors',
                    array('Label'),
                    array(array('data'=>'HtmlTag'), array('tag' => 'td', 'align'=>'right', 'class'=>'coluna')),                   
                   //array(array('row'=>'HtmlTag'),array('tag'=>'tr', 'openOnly'=>'true')),
           //array(array('row'=>'HtmlTag'),array('tag'=>'tr')),
           ));
       }
       else{
       		
       		$campo=$this->CreateElement('text',$coluna)
                   // ->setLabel('SSR:')
                    ->setValue($dados[$coluna])
                    ->addValidator('alnum')
                    ->setAttrib('size', 10)
                    ->setAttrib('maxLength', 10)
               		//->addValidator('regex', false, array('/^[a-z]+/'))
                    //->addValidator('stringLength', true, array(1, 1))
                    ->setRequired(true)
                    ->addFilter('StringToLower');

       $campo->setDecorators(array(
                   'ViewHelper',
                   'Description',
                   'Errors',
                    array('Label'),
                    array(array('data'=>'HtmlTag'), array('tag' => 'td', 'align'=>'right', 'class'=>'coluna')),                   
                   //array(array('row'=>'HtmlTag'),array('tag'=>'tr', 'openOnly'=>'true')),
           //array(array('row'=>'HtmlTag'),array('tag'=>'tr')),
           ));
       	
       }
          $this->addElement($campo);
       
       }
       
$submit=$this->CreateElement('submit','submit')


                       ->setLabel('Salvar');

  

       $submit->setDecorators(array(

  

               'ViewHelper',

               'Description',
               
               'Errors',                
                array(array('data'=>'HtmlTag'), array('tag' => 'td', 'class'=>'coluna', 'colspan'=>count($colunas)+2, 'align'=>'center')),
				array(array('row'=>'HtmlTag'),array('tag'=>'tr')),
             
       ));
       
       $this->addElement($submit);
       
              
       //$this->addSubForm(new Application_Form_Alelos(), 'sds');



   }

}
